package edu.wuster.blog.mapper;

import edu.wuster.blog.entity.Blogpart;
import org.apache.ibatis.annotations.*;


@Mapper
public interface BlogpartMapper {

    void addBlogpartSave(Blogpart blogpart);

    @Update("update blog set is_delete = 1 where id = #{id}")
    void deleteBlogpart(Integer id);

    @Select("select * from blog where id = #{id} and is_delete = 0")
    Blogpart selectById(Integer id);

    @Update("update blog set state = #{state} where id = #{id} and is_delete = 0")
    void resetById(Blogpart blogpart);

    @Update("update blog set like_num = like_num + 1 where id = #{id} and is_delete = 0")
    void addLike(Integer id);

    @Update("update blog set state = '审核中' , title = #{title} , text = #{text}," +
            "create_time = #{createTime} where id = #{id} ")
    void blogModify(Blogpart blogpart);

    @Update("update blog set like_num = like_num - 1 where id = #{blogId}")
    void reduceLike(Integer blogId);
}
